<?php
// 首页
$index = [
    'key'      => 'index',
    'name'     => '概况统计',
    'children' => [
        [
            'key'  => 'index-see',
            'name' => '查看权限'
        ]
    ],
];
// 账号管理
$admin = [
    'key'      => 'adm',
    'name'     => '账号管理',
    'children' => [
        [
            'key'      => 'admin',
            'name'     => '账号列表',
            'children' => [
                [
                    'key'  => 'admin-see',
                    'name' => '查看权限'
                ],
                [
                    'key'  => 'admin-mange',
                    'name' => '管理权限'
                ],
            ],
        ],
        [
            'key'      => 'adminrole',
            'name'     => '角色列表',
            'children' => [
                [
                    'key'  => 'adminrole-see',
                    'name' => '查看权限'
                ],
                [
                    'key'  => 'adminrole-mange',
                    'name' => '管理权限'
                ],
            ],
        ],
    ],
];
//地区
$location = [
    'key'      => 'location',
    'name'     => '地区管理',
    'children' => [
        [
            'key'      => 'housevillage',
            'name'     => '小区列表',
            'children' => [
                [
                    'key'  => 'housevillage-see',
                    'name' => '查看权限'
                ],
                [
                    'key'  => 'housevillage-mange',
                    'name' => '管理权限'
                ],
            ],
        ],
        [
            'key'      => 'businessarea',
            'name'     => '区域商圈列表',
            'children' => [
                [
                    'key'  => 'businessarea-see',
                    'name' => '查看权限'
                ],
                [
                    'key'  => 'businessarea-mange',
                    'name' => '管理权限'
                ],
            ],
        ],
        [
            'key'      => 'metro',
            'name'     => '地铁列表',
            'children' => [
                [
                    'key'  => 'metro-see',
                    'name' => '查看权限'
                ],
                [
                    'key'  => 'metro-mange',
                    'name' => '管理权限'
                ],
            ],
        ]
    ],
];
// 房源管理
$house = [
    'key'      => 'h',
    'name'     => '房源管理',
    'children' => [
        [
            'key'      => 'house',
            'name'     => '房源列表',
            'children' => [
                [
                    'key'  => 'house-see',
                    'name' => '查看权限'
                ],
                [
                    'key'  => 'house-mange',
                    'name' => '管理权限'
                ],
                [
                    'key'  => 'house-export',
                    'name' => '导出权限'
                ],
                [
                    'key'  => 'house-import',
                    'name' => '导入权限'
                ]
            ],
        ],
        [
            'key'      => 'importlog',
            'name'     => '导入日志',
            'children' => [
                [
                    'key'  => 'importlog-see',
                    'name' => '查看权限'
                ]
            ],
        ],
        [
            'key'      => 'housetraps',
            'name'     => '补漏房源',
            'children' => [
                [
                    'key'  => 'housetraps-see',
                    'name' => '查看权限'
                ],
                [
                    'key'  => 'housetraps-mange',
                    'name' => '管理权限'
                ]
            ],
        ]
    ],
];
// 成交情报
$deal = [
    'key'      => 'housestatistics',
    'name'     => '成交情报',
    'children' => [
        [
            'key'  => 'housestatistics-see',
            'name' => '查看权限'
        ],
        [
            'key'  => 'housestatistics-mange',
            'name' => '管理权限'
        ]
    ],
];
//公司
$company = [
    'key'      => 'company',
    'name'     => 'B端公司管理',
    'children' => [
        [
            'key'  => 'company-see',
            'name' => '查看权限'
        ],
        [
            'key'  => 'company-mange',
            'name' => '管理权限'
        ]
    ],
];
//消息管理
$message = [
    'key'      => 'message',
    'name'     => '消息管理',
    'children' => [
        [
            'key'      => 'userexperience',
            'name'     => '官网咨询',
            'children' => [
                [
                    'key'  => 'userexperience-see',
                    'name' => '查看权限'
                ],
                [
                    'key'  => 'userexperience-mange',
                    'name' => '管理权限'
                ]
            ]
        ],
        [
            'key'      => 'messagesystem',
            'name'     => '系统消息',
            'children' => [
                [
                    'key'  => 'messagesystem-see',
                    'name' => '查看权限'
                ],
                [
                    'key'  => 'messagesystem-mange',
                    'name' => '管理权限'
                ]
            ]
        ],
        [
            'key'      => 'messageagenthouse',
            'name'     => '智能选房消息',
            'children' => [
                [
                    'key'  => 'messageagenthouse-see',
                    'name' => '查看权限'
                ],
                [
                    'key'  => 'messageagenthouse-mange',
                    'name' => '管理权限'
                ]
            ]
        ]
    ]
];
//公告信息
$gonggao = [
    'key'      => 'gonggao',
    'name'     => '公告信息',
    'children' => [
        [
            'key'      => 'notice',
            'name'     => '公告/头条',
            'children' => [
                [
                    'key'  => 'notice-see',
                    'name' => '查看权限'
                ],
                [
                    'key'  => 'notice-mange',
                    'name' => '管理权限'
                ]
            ]
        ],
        [
            'key'      => 'adver',
            'name'     => '开屏广告',
            'children' => [
                [
                    'key'  => 'adver-see',
                    'name' => '查看权限'
                ],
                [
                    'key'  => 'adver-mange',
                    'name' => '管理权限'
                ]
            ]
        ],
        [
            'key'      => 'banner',
            'name'     => '轮播图',
            'children' => [
                [
                    'key'  => 'banner-see',
                    'name' => '查看权限'
                ],
                [
                    'key'  => 'banner-mange',
                    'name' => '管理权限'
                ]
            ]
        ]
    ]
];
//法拍课堂
$fapaiketang = [
    'key'      => 'fapaiketang',
    'name'     => '法拍课堂',
    'children' => [
        [
            'key'      => 'teacherforum',
            'name'     => '名师讲堂',
            'children' => [
                [
                    'key'  => 'teacherforum-see',
                    'name' => '查看权限'
                ],
                [
                    'key'  => 'teacherforum-mange',
                    'name' => '管理权限'
                ]
            ]
        ],
        [
            'key'      => 'wiki',
            'name'     => '法拍百科',
            'children' => [
                [
                    'key'  => 'wiki-see',
                    'name' => '查看权限'
                ],
                [
                    'key'  => 'wiki-mange',
                    'name' => '管理权限'
                ]
            ]
        ]
    ]
];

//日志管理
$logs = [
    'key'      => 'logs',
    'name'     => '日志管理',
    'children' => [
        [
            'key'      => 'systemlog',
            'name'     => '系统日志',
            'children' => [
                [
                    'key'  => 'systemlog-see',
                    'name' => '查看权限'
                ]
            ]
        ],
        [
            'key'      => 'loginlog',
            'name'     => '登录日志',
            'children' => [
                [
                    'key'  => 'loginlog-see',
                    'name' => '查看权限'
                ]
            ]
        ]
    ]
];

//编辑角色权限所需角色树，按实际顺序排
$tree = [$index, $house, $deal, $location, $company, $admin, $message, $gonggao, $logs];
//超管的角色详情，来自角色树的所有最小级
$allAuth = ['admin-see', 'admin-mange', 'adminrole-see', 'adminrole-mange', 'housevillage-see', 'housevillage-mange', 'businessarea-see', 'businessarea-mange', 'metro-see', 'metro-mange', 'index-see', 'house-see', 'house-mange', 'house-export', 'house-import', 'importlog-see', 'housetraps-see', 'housetraps-mange', 'housestatistics-see', 'housestatistics-mange', 'company-see', 'company-mange', 'userexperience-see', 'userexperience-mange', 'notice-see', 'notice-mange', 'teacherforum-see', 'teacherforum-mange', 'wiki-see', 'wiki-mange', 'adver-see', 'adver-mange', 'banner-see', 'banner-mange', 'messagesystem-mange', 'messagesystem-see', 'messageagenthouse-mange', 'messageagenthouse-see', 'systemlog-see', 'loginlog-see'];

//一级和二级映射关系
$relationship = [
    'admin'             => 'adm',
    'adminrole'         => 'adm',
    'housevillage'      => 'location',
    'businessarea'      => 'location',
    'metro'             => 'location',
    'house'             => 'h',
    'importlog'         => 'h',
    'housetraps'        => 'h',
    'notice'            => 'gonggao',
    'adver'             => 'gonggao',
    'banner'            => 'gonggao',
    'teacherforum'      => 'fapaiketang',
    'wiki'              => 'fapaiketang',
    'userexperience'    => 'message',
    'messagesystem'     => 'message',
    'messageagenthouse' => 'message',
    'systemlog'         => 'logs',
    'loginlog'          => 'logs',
];
return [

    'relationship' => $relationship,

    'tree' => $tree,

    'all_auth'       => $allAuth,

    // 权限依赖，查看权限
    'rely'           => [
        // 账号依赖：角色
        'admin'        => ['adminrole'],
        // 角色依赖：账号
        'adminrole'    => ['admin'],
        // 公司依赖：公司账号
        'company'      => ['companyaccount'],
        // 房源依赖：区域、拍卖
        'house'        => ['houseauction'],
        // 小区依赖：区域，热门小区
        'housevillage' => ['hotvallige'],
        //导入日志
        'importlog'    => ['importerrlog'],
        // 首页依赖：房源
        'index'        => ['house'],
    ],

    /**
     * 权限级别关系
     * 1查看权限、2管理权限、4导出|下载权限、8导入权限
     */
    'level_relation' => [
        1 => 'see',
        2 => 'mange',
        4 => 'export',
        8 => 'import',
    ],

    // 权限和
    'level_count'    => [
        1  => [1],
        3  => [1, 2],
        5  => [1, 4],
        9  => [1, 8],
        7  => [1, 2, 4],
        11 => [1, 2, 8],
        13 => [1, 4, 8],
        15 => [1, 2, 4, 8]
    ],

    /**
     * 权限控制器 数据库保存的控制器
     */
    'level'          => ['admin', 'adminrole', 'businessarea', 'company', 'house', 'housestatistics', 'housetraps', 'housevillage', 'index', 'metro', 'importlog', 'userexperience', 'notice', 'teacherforum', 'wiki', 'adver', 'banner', 'messagesystem', 'messageagenthouse', 'systemlog', 'loginlog'],

];